function fig_s_functions(R1_grid, s_hatR, s_starR, delta_grid, s_hat, s_star, s_min, s_max, ...
    prob_fail, prob_fail_F, prob_fail_R, prob_fail_F_R, optfig)

if optfig.plotfig == 1
    
    [fontname,dimension,lw,folder,color,style,~,~,fontsize_tit,~,fontsize_lab,fontsize_leg] = fn_optfig(optfig);
    
    f0 = figure('Units','inches','Position',dimension);
    
    subplot(2,1,1)
    p1 = plot(R1_grid,s_starR,'Color',color{1},'LineWidth',lw,'LineStyle',style{1}); hold on;
    p2 = plot(R1_grid,s_hatR, 'Color',color{2},'LineWidth',lw,'LineStyle',style{3}); hold on;
    plot(R1_grid,s_max*ones(size(s_starR)),'Color',color{6},'LineWidth',lw,'LineStyle',style{2}); hold on;
    %     title('$s^*(R_1,\delta)$ and $\hat{s}(R_1)$','interpreter','latex','FontSize',fontsize,'FontName',fontname);
    xlabel('Deposit Rate $(R_1)$','interpreter','latex','FontSize',fontsize_lab);
    % str = ['R_1 = ',num2str(R1)]; text(sMax,rho2(end),str,'HorizontalAlignment','right');
    grid; axis tight; box off;
    legend([p1,p2],{'$s^*(\delta, R_1)$','$\hat{s}(R_1)$'},'interpreter','latex',...
        'FontSize',fontsize_leg,'FontName',fontname,'Location','northoutside', 'Orientation', 'horizontal')
    legend('boxoff')
    
    subplot(2,1,2)
    plot(R1_grid,prob_fail_R,  'Color',color{1},'LineWidth',lw); hold on;
    plot(R1_grid,prob_fail_F_R,'Color',color{5},'LineWidth',lw,'LineStyle',style{2});
    %     title('$q(R_1,\delta)$','interpreter','latex','FontSize',fontsize,'FontName',fontname);
    xlabel('Deposit Rate $(R_1)$','interpreter','latex','FontSize',fontsize_lab);
    grid; axis tight; box off;
    legend({'Failure Probability $q^F(R_1,\delta)$','Fundamental Failure Probability'},'interpreter','latex',...
        'FontSize',fontsize_leg,'FontName',fontname,'Location','best')
    legend('boxoff')
    
    f1 = figure('Units','inches','Position',dimension);
    
    %     subplot(2,1,1)
    plot(delta_grid,s_min*ones(size(s_star)),'Color',color{6},'LineWidth',lw,'LineStyle',style{2}); hold on;
    plot(delta_grid,s_max*ones(size(s_star)),'Color',color{6},'LineWidth',lw,'LineStyle',style{2}); hold on;
    p1 = plot(delta_grid,s_star,'Color',color{1},'LineWidth',lw,'LineStyle',style{1});
    p2 = plot(delta_grid,s_hat, 'Color',color{2},'LineWidth',lw,'LineStyle',style{3});
        title('Regions Defined by $s^{*}\left(\delta,R_{1}\right)$ and $\hat{s}\left(R_{1}\right)$','interpreter','latex','FontSize',fontsize_tit,'FontName',fontname);
    xlabel('Deposit Insurance ($\delta$)','interpreter','latex','FontSize',fontsize_lab,'FontName',fontname)
    axis([min(delta_grid),max(delta_grid),s_min*0.95,s_max+0.05]);
    grid; box off;
    legend([p1,p2],{'$s^*(\delta, R_1)$','$\hat{s}(R_1)$'},'interpreter','latex',...
        'FontSize',fontsize_leg,'FontName',fontname,'Location','best', 'Orientation', 'vertical')
    legend('boxoff')
    
    %     subplot(2,1,2)
    %     plot(delta_grid,prob_fail,  'Color',color{1},'LineWidth',lw); hold on;
    %     plot(delta_grid,prob_fail_F,'Color',color{6},'LineWidth',lw,'LineStyle',style{2}); hold on;
    %     %     title('$q(R_1,\delta)$','interpreter','latex','FontSize',fontsize,'FontName',fontname);
    %     % str = ['R_1 = ',num2str(R1)]; text(sMax,rho2(end),str,'HorizontalAlignment','right');
    %     xlabel('Deposit Insurance ($\delta$)','interpreter','latex','FontSize',fontsize_lab,'FontName',fontname)
    %     axis([min(delta_grid),max(delta_grid),min(prob_fail_F)*0.9,max(prob_fail)*1.05]);
    %     grid; box off;
    %     legend({'Failure Probability $q^F(R_1,\delta)$','Fundamental Failure Probability'},'interpreter','latex',...
    %         'FontSize',fontsize_leg,'FontName',fontname,'Location','northeast')
    %     legend('boxoff')
    
    name = 's_star_R1';
    print(f0,'-depsc','-painters','-noui','-r600',[folder,name,'.eps'])
    name = 's_star_delta';
    print(f1,'-depsc','-painters','-noui','-r600',[folder,name,'.eps'])
    
    if optfig.close == 1; close(f0); close(f1); end
    
end
